package com.starlink.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.starlink.model.domain.SchoolbagBooksStorageDO;
import com.starlink.model.request.SchoolbagBooksStorageRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface SchoolbagBooksStorageMapper extends BaseMapper<SchoolbagBooksStorageDO> {
    SchoolbagBooksStorageDO selectDOById(Long id);
    List<SchoolbagBooksStorageDO> selectDOList(SchoolbagBooksStorageDO schoolbagBooksStorage);
    int insertDO(SchoolbagBooksStorageDO schoolbagBooksStorage);
    int batchInsertDO(List<SchoolbagBooksStorageDO> schoolbagBooksStorageDOList);
    int updateDO(SchoolbagBooksStorageDO schoolbagBooksStorage);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from schoolbag_books_storage",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") SchoolbagBooksStorageRequest param);
    @Select({"<script>",
            "   select * from schoolbag_books_storage",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<SchoolbagBooksStorageDO> pageQuery(@Param("param") SchoolbagBooksStorageRequest param, @Param("limit") int limit, @Param("offset") long offset);

    Integer countByBooksId(Long booksId);

    List<SchoolbagBooksStorageDO> listQuery(SchoolbagBooksStorageRequest request);

    List<SchoolbagBooksStorageDO> listQueryByBagId(Long schoolbagGroupBagDOId);
}
